﻿using DalatCooking.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_Polls_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            ListPolls();
        }
    }
    private void ListPolls()
    {
        gvPolls.DataSource = PollManager.FindAllPoll().Tables[0];
        gvPolls.DataBind();
    }

    protected void gvPolls_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int pollID = int.Parse(gvPolls.DataKeys[e.RowIndex]["PollID"].ToString());

        PollManager.Delete(pollID);

        divMsg.InnerHtml = "<b>Thông tin:</b> Xóa bình chọn thành công.";
        divMsg.Visible = true;
        ListPolls();
    }
    public int Count()
    {

        return gvPolls.Rows.Count;
    }
}
